package user_wash

import (
	"context"

	"gitee.com/liuxuezhan/ar-platform/rpc-client/assetsClient/client/userwash"
	"github.com/jinzhu/copier"

	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/svc"
	"gitee.com/liuxuezhan/ar-platform/admin-api/internal/types"

	"github.com/zeromicro/go-zero/core/logx"
)

type UserWashListLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

// 洗码页面--洗码列表
func NewUserWashListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *UserWashListLogic {
	return &UserWashListLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *UserWashListLogic) UserWashList(req *types.UserWashListRequest) (resp *types.UserWashListResponse, err error) {
	resp = &types.UserWashListResponse{
		Data: []types.UserWashListPageResponse_Data{},
		Meta: types.UserWashListPageResponse_Meta{},
	}

	userWashList, err := l.svcCtx.AssetsRpc.UserWash.UserWashList(l.ctx, &userwash.UserWashListRequest{
		UserId:   req.UserId,
		TypeName: req.TypeName,
		Page:     req.Page,
		PageSize: req.PageSize,
	})
	if err != nil {
		return nil, err
	}

	copier.Copy(&resp.Data, &userWashList.List)
	copier.Copy(&resp.Meta, &userWashList.Meta)
	return
}
